//////////////////////////////////////////////////////////////////////////////////
//
//	Invisible
//		- Version 1.1
//		- 07.09.2006
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
// - Running the command on clients will toggle their visibility
// - Defualt admin level is ADMIN_BAN
//
// COMMANDS: 
//	amx_invisible <nick | steam>	//Toggle invisibility on user
//	
// Changelog:
//
// - 02.11.2006 Version 1.0
//	Initial release
//
// - 07.09.2006 Version 1.1
//	Replaced ENGINE with FAKEMETA
//
//////////////////////////////////////////////////////////////////////////////////

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new invisible[33];

public plugin_init()
{
	register_plugin("Invisible","1.1","diamond-optic")
	
	register_cvar("amx_invisible_stats", "1.1", FCVAR_SERVER|FCVAR_SPONLY)
	
	register_concmd("amx_invisible","invisibility",ADMIN_BAN,"<nick | steam> - toggle invisibility on user")
}
public client_putinserver(id) {
	invisible[id] = 0;
}
public invisibility(id,level,cid) {
	if(!cmd_access(id,level,cid,0)) {
		return PLUGIN_HANDLED
	}
	
	new readname[256];
	read_argv(1,readname,255);
	new playername = cmd_target(id,readname,2);
	
	if(invisible[playername] ==  0)	
			{
			invisible[playername] = 1
			fm_set_entity_visibility(playername, 0)
			client_print(id,print_chat,"Invisiblilty turned ON for %s",playername)
			}
		else
			{
			invisible[playername] = 0
			fm_set_entity_visibility(playername, 1)
			client_print(id,print_chat,"Invisibility turned OFF for %s",playername)
			}
	return PLUGIN_HANDLED
}

stock fm_set_entity_visibility(index, visible = 1)	//from fakemeta_util
{
	set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)

	return 1
}
